package `object`

/**
 *
 *   @project kotlin-docs
 *   @author  be7364
 *   @datetime 2020/9/28 12:04
 *
 */

class Person1

// name是主构造函数的入参
class Person2 constructor(name: String)

class Person3 constructor(name: String) {
    var age: Int = 0
    var name: String = name
    init {
        println("init")
    }

    init {
        println("name=$name, age=$age")
    }
}

// 定义了属性name和主构造函数的入参
class Person4 constructor(var name: String)


fun main() {
    println("object")
    var person1: Person1? = null
    println(person1)

    var person2 = Person2("name")
    //object.Person2@610455d6
    println(person2)


    println("before init")
    var person3 = Person3("Tom").also(::println)
    println("after init")
    println(person3.age)

    var person4 = Person4("person4")
    println(person4.name)
}